<?php
	class Admin_model extends Model
		{
			function Admin_model()
			{
				parent::Model();
			}
			
			function insertcitylist($cityname,$type,$parentid)
			{
				$returnvalue=0;
				if(strlen($cityname) > 0)
				{
					$qry =" select * from citylist where cityname = ? ";
				$query = $this->db->query($qry,array($cityname));
				if($query->num_rows()>0)
				{ 
				$returnvalue =  -1 ;				
				}
				else
				{
				$data=array('cityname'=>$cityname,'parentid'=>$parentid,'type'=>$type);
				$value=$this->db->insert('citylist',$data);
				$returnvalue=$this->db->insert_id(); 
				}
				}
				return $returnvalue;
			}
			
			function fetchcitylistpage($num,$offset)
			{
				$testarr=array();
				$qry="select * from citylist where type=0 limit " . $num . "," . $offset;
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('cityid'=>$row->cityid,'cityname'=>$row->cityname);
					}
				}
				return $testarr;
			}
			
			function fetchcitylist()
			{
				
				$testarr=array();
				$qry="select * from citylist where type=0 order by cityname";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
				foreach($rs->result() as $row)
                {
                    $cityid = $row->cityid;
					$cityname=$row->cityname;
                    $qry = "select * from citylist where parentid = ? order by cityname";
					$rs=$this->db->query($qry,array($cityid));
                    $localityarray = array();
					if($rs->num_rows()>0)
					{
                    foreach($rs->result() as $row)
                    {
                        $localityarray[] = array("cityid"=>$row->cityid,"cityname"=>$row->cityname);
                    }
					}
                   $testarr[]= array("cityid"=>$cityid,"cityname"=>$cityname , "localityarray"=>$localityarray);           
                }}
				return $testarr;
				
			}
			
			function insertcityarea($city,$cityarea,$type)
			{
				$returnvalue=0;
				if(strlen($cityarea) > 0)
				{
					$qry =" select * from citylist where cityname = ? ";
				$query = $this->db->query($qry,array($cityarea));
				if($query->num_rows()>0)
				{ 
				$returnvalue =  -1 ;				
				}
				else
				{
				$data=array('cityname'=>$cityarea,'parentid'=>$city,'type'=>$type);
				$value=$this->db->insert('citylist',$data);
				$returnvalue=$this->db->insert_id(); 
				}
				}
				return $returnvalue;
				
				
			}
			
			function fetchcityarea()
			{
				$testarr=array();
				$qry="select c.cityid,c.cityname from citylist c where type=1 and c.parentid=c.cityid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('cityid'=>$row->cityid,'cityname'=>$row->cityname);
					}
				}
				return $testarr;
			}
			function fetchcityareapage($num,$offset)
			{
				$testarr=array();
				$qry="select c.cityid,c.cityname from citylist c where type=1  limit " . $num . "," . $offset;
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('cityid'=>$row->cityid,'cityname'=>$row->cityname);
					}
				}
				return $testarr;
			}
			
			function fetchpropertytype($propertytype)
			{
				$qry="select typeid from property_type where propertytype=?";
				$rs=$this->db->query($qry,array($propertytype));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$typeid=$row->typeid;
					}
				}
				return $typeid;
			}
						
			function insertcategory($proptype,$category)
			{
				$returnvalue=0;
				if(strlen($category) > 0)
				{
					$qry =" select * from category where propertytypeid = ? and categoryname=?";
				$query = $this->db->query($qry,array($proptype,$category));
				if($query->num_rows()>0)
				{ 
				$returnvalue =  -1 ;				
				}
				else
				{
				$data=array('propertytypeid'=>$proptype,'categoryname'=>$category);
				$value=$this->db->insert('category',$data);
				$returnvalue=$this->db->insert_id(); 
				}
				}
				return $returnvalue;
				
			}
			
			function fetchcategory()
			{
				$testarr=array();
				$qry="select * from category inner join property_type on category.propertytypeid=property_type.typeid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertytype'=>$row->propertytype,'categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchcategorypage($num,$offset)
			{
				$testarr=array();
				$qry="select * from category inner join property_type on category.propertytypeid=property_type.typeid limit " . $num . "," . $offset;
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertytype'=>$row->propertytype,'categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchcategoryname($var1)
			{
				$qry="select categoryname from category where categoryid=?";
				$rs=$this->db->query($qry,array($var1));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$categoryname=$row->categoryname;
					}
				}
				return $categoryname;
			}
			
			function fetchcategorylist()
			{
				$testarr=array();
				$qry="select categoryid,categoryname from category where propertytypeid=3 ";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchcommercialcategoryname()
			{
				$testarr=array();
				$qry="select categoryid,categoryname from category where propertytypeid=4 ";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchresidentialcategory($propertytype)
			{
				$testarr=array();
				$qry="select * from category where propertytypeid in (select typeid from property_type where propertytype=?)";
				$rs=$this->db->query($qry,array($propertytype));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('categoryid'=>$row->categoryid,'propertytypeid'=>$row->propertytypeid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchcommercialcategory($propertytype)
			{
				$testarr=array();
				$qry="select * from category where propertytypeid in(select typeid from property_type where propertytype=?)";
				$rs=$this->db->query($qry,array($propertytype));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function insertproptype($proptype)
			{
				$returnvalue=0;
				if(strlen($proptype) > 0)
				{
					$qry =" select * from property_type where propertytype = ? ";
				$query = $this->db->query($qry,array($proptype));
				if($query->num_rows()>0)
				{ 
				$returnvalue =  -1 ;				
				}
				else
				{
				$data=array('propertytype'=>$proptype);
				$value=$this->db->insert('property_type',$data);
				$returnvalue=$this->db->insert_id(); 
				}
				}
				return $returnvalue;
				
				
			}
			
			function fetchproptype()
			{
				$testarr=array();
				$qry="select * from property_type";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('typeid'=>$row->typeid,'propertytype'=>$row->propertytype);
					}
				}
				return $testarr;
			}
			
			function insertapartmentpropertydetails($propertyname,$name,$address,$buildername,$name1,$project,$developer,$lat,$long,$propertycategory,$propertytype,$propertycity)
			{
				$data=array('property_name'=>$propertyname,'property_logo'=>$name,'address'=>$address,'builders_name'=>$buildername,'builders_logo'=>$name1,'aboutproject'=>$project,'aboutdeveloper'=>$developer,'latitudes'=>$lat,'longitudes'=>$long,'categoryid'=>$propertycategory,'propertytypeid'=>$propertytype,'cityid'=>$propertycity);
				$this->db->insert('propertymaster',$data);
				return $this->db->insert_id();
			}
			
			function inserttowerdesc($propertyid=0,$towername="",$floornumber=0,$apartmentsperfloor=0,$completion,$possession,$ongoing=0,$prelaunch=0)
			{
				$data=array('propertyid'=>$propertyid,'tower_name'=>$towername,'number_of_floors'=>$floornumber,'apartmentsperfloor'=>$apartmentsperfloor,'completion_date'=>$completion,'possession_date'=>$possession,'ongoing'=>$ongoing,'prelaunch'=>$prelaunch);
				$this->db->insert('propertyapartmenttowerdesc',$data);
				return $this->db->insert_id();
			}
			
			function fetchtowerdesc()
			{
				$testarr=array();
				$qry="select at.towerdescid,at.tower_name,pm.property_name,at.number_of_floors,at.apartmentsperfloor from propertyapartmenttowerdesc at inner join propertymaster pm on at.propertyid=pm.propertyid ";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('towerdescid'=>$row->towerdescid,'towername'=>$row->tower_name,'propertyname'=>$row->property_name,'numberoffloors'=>$row->number_of_floors,'apartmentsperfloor'=>$row->apartmentsperfloor);
					}
				}
				return $testarr;
			}
			
			function insertpropertydetails($propertyname="",$name="",$address="",$buildername="",$name1="",$project="",$developer="",$lat="",$long="",$propertycategory="",$propertytype="",$propertycity="")
			{
				$data=array('property_name'=>$propertyname,'property_logo'=>$name,'address'=>$address,'builders_name'=>$buildername,'builders_logo'=>$name1,'aboutproject'=>$project,'aboutdeveloper'=>$developer,'latitudes'=>$lat,'longitudes'=>$long,'categoryid'=>$propertycategory,'propertytypeid'=>$propertytype,'cityid'=>$propertycity);
				$this->db->insert('propertymaster',$data);
				return $this->db->insert_id();
			}
			
			function insertaddpropertydetails($propertyid="",$propertybedrooms="",$propertyprice="",$propertylandarea="",$propertybuiltuparea="",$propertycompletion="",$propertypossession="",$ongoing="",$prelaunch="")
			{
				$data=array('propertyid'=>$propertyid,'number_of_bedrooms'=>$propertybedrooms,'land_area'=>$propertylandarea,'built_up_area'=>$propertybuiltuparea,'price'=>$propertyprice,'completion_date'=>$propertycompletion,'possession_date'=>$propertypossession,'ongoing'=>$ongoing,'prelaunch'=>$prelaunch);
				$this->db->insert('propertyresidentialaddproperty',$data);
				return $this->db->insert_id();
			}
			
			function fetchproperty()
			{
				$testarr=array();
				$qry="select * from propertymaster";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'property_name'=>$row->property_name,'builders_name'=>$row->builders_name,'address'=>$row->address);
					}
				}
				return $testarr;
			}
			
			function fetchpropertypage($num,$offset)
			{
				$testarr=array();
				$qry="select * from propertymaster pm inner join category c on pm.categoryid=c.categoryid limit " . $num . "," . $offset;
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'property_name'=>$row->property_name,'builders_name'=>$row->builders_name,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function fetchpropertyname($propertyid)
			{
				$qry="select propertyid,property_name from propertymaster where propertyid=?";
				$rs=$this->db->query($qry,array($propertyid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						
						$propertyname=$row->property_name;
					}
				}
				return $propertyname;
			}
			
			function fetchpropertycategorywise()
			{
				$testarr=array();
				$qry="select pm.propertyid,pm.property_name from propertymaster pm inner join category c on pm.categoryid=c.categoryid where c.categoryid=9";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name);
					}
				}
				return $testarr;
			}
			
			function fetchpropertyvilla()
			{
				$testarr=array();
				$qry="select pm.propertyid,pm.property_name from propertymaster pm inner join category c on pm.categoryid=c.categoryid where c.categoryid=10";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name);
					}
				}
				return $testarr;
			}
			
			function fetchpropertyindependenthouse()
			{
				$testarr=array();
				$qry="select pm.propertyid,pm.property_name from propertymaster pm inner join category c on pm.categoryid=c.categoryid where c.categoryid=13";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name);
					}
				}
				return $testarr;
			}
			
			function insertfloorplan($propertyname,$floorplantype,$floorsize,$floorprice,$pricepersqft,$newfilename,$thumbfilename)
			{
				$data=array('propertyid'=>$propertyname,'plantype'=>$floorplantype,'floorsize'=>$floorsize,'price'=>$floorprice,'pricepersqft'=>$pricepersqft,'floorplanimg'=>$newfilename,'floorthumbimg'=>$thumbfilename);
				$this->db->insert('property_floorplan',$data);
				return $this->db->insert_id();
			}
			
			function insertapartmentfloorplan($tower="",$ap_bedrooms="",$ap_range1="",$ap_range2="",$ap_price="",$ap_additional="",$newfilename="",$thumbfilename="")
			{
				$data=array('towerdescid'=>$tower,'bedrooms'=>$ap_bedrooms,'area1'=>$ap_range1,'area2'=>$ap_range2,'price'=>$ap_price,'additional_rooms'=>$ap_additional,'floorimg'=>$newfilename,'floorthumbimg'=>$thumbfilename);
				$this->db->insert('apartmenttowerfloorplan',$data);
				return $this->db->insert_id();
			}
			
			function fetchapartmentfloorplan()
			{
				$testarr=array();
				$qry="select * from apartmenttowerfloorplan inner join propertyapartmenttowerdesc on apartmenttowerfloorplan.towerdescid=propertyapartmenttowerdesc.towerdescid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('floorplanid'=>$row->floorplanid,'towername'=>$row->tower_name,'bedrooms'=>$row->bedrooms,'floorplanimg'=>$row->floorimg,'floorthumbimg'=>$row->floorthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertvillafloorplan($vi_property="",$vi_type="",$newfilename="",$thumbfilename="")
			{
				$data=array('propertyid'=>$vi_property,'floorplantype'=>$vi_type,'floorimg'=>$newfilename,'floorthumbimg'=>$thumbfilename);
				$this->db->insert('propertyresidentialfloorplan',$data);
				return $this->db->insert_id();
			}
			
			function fetchvillafloorplan()
			{
				$testarr=array();
				$qry="select * from propertyresidentialfloorplan inner join propertymaster on propertyresidentialfloorplan.propertyid=propertymaster.propertyid where propertymaster.categoryid=10";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('floorplanid'=>$row->floorplanid,'propertyname'=>$row->property_name,'plantype'=>$row->floorplantype,'floorplanimg'=>$row->floorimg,'floorthumbimg'=>$row->floorthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertindependenthousefloorplan($ih_property,$ih_type,$newfilename,$thumbfilename)
			{
				$data=array('propertyid'=>$ih_property,'floorplantype'=>$ih_type,'floorimg'=>$newfilename,'floorthumbimg'=>$thumbfilename);
				$this->db->insert('propertyresidentialfloorplan',$data);
				return $this->db->insert_id();
			}
			
			function fetchindependenthousefloorplan()
			{
				$testarr=array();
				$qry="select * from propertyresidentialfloorplan inner join propertymaster on propertyresidentialfloorplan.propertyid=propertymaster.propertyid where propertymaster.categoryid=13";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('floorplanid'=>$row->floorplanid,'propertyname'=>$row->property_name,'plantype'=>$row->floorplantype,'floorplanimg'=>$row->floorimg,'floorthumbimg'=>$row->floorthumbimg);
					}
				}
				return $testarr;
			}
			
			function fetchpropertyfloor()
			{
				$testarr=array();
				$qry="select * from propertyresidentialfloorplan inner join propertymaster on propertyresidentialfloorplan.propertyid=propertymaster.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('floorplanid'=>$row->floorplanid,'property_name'=>$row->property_name,'plantype'=>$row->floorplantype,'floorplanimg'=>$row->floorimg,'floorthumbimg'=>$row->floorthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertcommercialpropertydetails($propertyname="",$name="",$buildername="",$name1="",$address="",$project="",$developer="",$lat="",$long="",$propertycategory="",$propertycity="",$propertytype="")
			{
				$data=array('property_name'=>$propertyname,'property_logo'=>$name,'builders_name'=>$buildername,'builders_logo'=>$name1,'address'=>$address,'aboutproject'=>$project,'aboutdeveloper'=>$developer,'latitudes'=>$lat,'longitudes'=>$long,'categoryid'=>$propertycategory,'propertytypeid'=>$propertytype,'cityid'=>$propertycity);
				$this->db->insert('propertymaster',$data);
				return $this->db->insert_id();
			}
			
			function insertcommercialaddproperty($commercialpropertyid="",$propertyfloors="",$ongoing="",$prelaunch="",$propertycompletion="",$propertypossession="")
			{
				$data=array('propertyid'=>$commercialpropertyid,'number_of_floors'=>$propertyfloors,'completion_date'=>$propertycompletion,'possession'=>$propertypossession,'ongoing'=>$ongoing,'prelaunch'=>$prelaunch);
				$this->db->insert('propertycommercial',$data);
				return $this->db->insert_id();
			}
			
			function fetchcommercialproperty()
			{
				$testarr=array();
				$qry="select * from propertycommercial";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertycommercialid'=>$row->propertycommercialid,'propertycommercialname'=>$row->propertycommercialname,'builders_name'=>$row->builders_name,'price'=>$row->price,'address'=>$row->address,'builtup_area'=>$row->builtup_area,'number_of_floors'=>$row->number_of_floors);
					}
				}
				return $testarr;
			}
			
			function fetchcommercialprojectname()
			{
				$testarr=array();
				$qry="select * from propertymaster where propertytypeid=4";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name);
					}
				}
				return $testarr;
			}
			
			function fetchcommercialpropertypage($num,$offset)
			{
				$testarr=array();
				$qry="select * from propertycommercial pc inner join propertymaster pm on pc.propertyid=pm.propertyid limit " . $num . "," . $offset;
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name,'builders_name'=>$row->builders_name,'number_of_floors'=>$row->number_of_floors);
					}
				}
				return $testarr;
			}
			
			function insertcommercialfloorplan($commercialpropertyname,$commercialfloorsize,$pricepersqft,$name)
			{
				$data=array('propertycommercialid'=>$commercialpropertyname,'floorsize'=>$commercialfloorsize,'pricepersqft'=>$pricepersqft,'commercialfloorplanimg'=>$name);
				$this->db->insert('propertycommercial_floorplan',$data);
				return $this->db->insert_id();
			}
			
			function insertcommercialpropertyfloorplan($commercialpropertyname="",$commercialfloorsize="",$pricepersqft="",$newfilename="",$thumbfilename="")
			{
				$data=array('propertyid'=>$commercialpropertyname,'floorsize'=>$commercialfloorsize,'pricepersqft'=>$pricepersqft,'commercialfloorplanimg'=>$newfilename,'floorthumbimg'=>$thumbfilename);
				$this->db->insert('propertycommercial_floorplan',$data);
				return $this->db->insert_id();
			}
			
			function fetchcommercialpropertyfloor()
			{
				$testarr=array();
				$qry="select * from propertycommercial_floorplan inner join propertymaster on propertymaster.propertyid=propertycommercial_floorplan.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('commercialfloorplanid'=>$row->commercialfloorplanid,'propertyname'=>$row->property_name,'floorsize'=>$row->floorsize,'pricepersqft'=>$row->pricepersqft,'commercialfloorplanimg'=>$row->commercialfloorplanimg,'floorthumbimg'=>$row->floorthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertcommercialplan($commercialpropertyname,$commercialimagetype,$name,$name1)
			{
				$data=array('propertyid'=>$commercialpropertyname,'imagetype'=>$commercialimagetype,'planimage'=>$name,'planthumbimg'=>$name1);
				$this->db->insert('propertycommercial_plan',$data);
				return $this->db->insert_id();
			}
			
			function fetchcommercialplan()
			{
				$testarr=array();
				$qry="select * from propertycommercial_plan inner join propertymaster on propertymaster.propertyid=propertycommercial_plan.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('planid'=>$row->planid,'propertyname'=>$row->property_name,'imagetype'=>$row->imagetype,'planimage'=>$row->planimage,'planthumbimg'=>$row->planthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertresidentialplan($residentialpropertyname="",$residentialimagetype="",$name="",$thumbfilename="")
			{
				$data=array('propertyid'=>$residentialpropertyname,'plantype'=>$residentialimagetype,'planimg'=>$name,'planthumbimg'=>$thumbfilename);
				$this->db->insert('propertyresidentialplan',$data);
				return $this->db->insert_id();
			}
			
			function fetchresidentplan()
			{
				$testarr=array();
				$qry="select * from propertyresidentialplan inner join propertymaster on propertymaster.propertyid=propertyresidentialplan.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('planid'=>$row->planid,'property_name'=>$row->property_name,'imagetype'=>$row->plantype,'planimage'=>$row->planimg,'planthumbimg'=>$row->planthumbimg);
					}
				}
				return $testarr;
			}
			
			function insertcommercialamenities($commercialpropertyname,$commercialamenities)
			{
				$data=array('propertyid'=>$commercialpropertyname,'commercialamenities_name'=>$commercialamenities);
				$this->db->insert('commercialamenities',$data);
				return $this->db->insert_id();
			}
			
			function fetchcommercialamenities()
			{
				$testarr=array();
				$qry="select pm.property_name,c.commercialamenitiesid,c.commercialamenities_name from commercialamenities c inner join propertymaster pm on c.propertyid=pm.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('commercialamenitiesid'=>$row->commercialamenitiesid,'propertyname'=>$row->property_name,'commercialamenities_name'=>$row->commercialamenities_name);
					}
				}
				return $testarr;
			}
			
			function insertresidentialspecification($propertyname,$specificationname)
			{
				$data=array('propertyid'=>$propertyname,'specification_name'=>$specificationname);
				$this->db->insert('residentialspecification',$data);
				return $this->db->insert_id();
			}
			
			function fetchspecification()
			{
				$testarr=array();
				$qry="select rs.specification_id,pm.property_name,rs.specification_name from residentialspecification rs inner join propertymaster pm on rs.propertyid=pm.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('specification_id'=>$row->specification_id,'property_name'=>$row->property_name,'specification_name'=>$row->specification_name);
					}
				}
				return $testarr;
			}
			
			function insertresidentialamenitiesname($propertyname,$propertyamenities)
			{
				$data=array('propertyid'=>$propertyname,'amenities_name'=>$propertyamenities);
				$this->db->insert('residentialamenities',$data);
				return $this->db->insert_id();
			}
			
			function fetchamenities()
			{
				$testarr=array();
				$qry="select ra.residentialamenitiesid,pm.property_name,ra.amenities_name from residentialamenities ra inner join propertymaster pm on ra.propertyid=pm.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('amenitiesid'=>$row->residentialamenitiesid,'propertyname'=>$row->property_name,'amenitiesname'=>$row->amenities_name);
					}
				}
				return $testarr;
			}
			
			function insertresidentialamenities($propertyname,$amenitiesname)
			{
				$data=array('propertyid'=>$propertyname,'amenities_name'=>$amenitiesname);
				$this->db->insert('residentialamenities',$data);
				return $this->db->insert_id();
			}
			
			function fetchresidentialamenities()
			{
				$testarr=array();
				$qry="select ra.residentialamenitiesid,pm.property_name,ra.amenities_name from residentialamenities ra inner join propertymaster pm on ra.propertyid=pm.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('residentialamenitiesid'=>$row->residentialamenitiesid,'property_name'=>$row->property_name,'amenities_name'=>$row->amenities_name);
					}
				}
				return $testarr;
			}
			
			function insertcommercialcaption($commercialpropertyname,$commercialcaption,$newfilename,$thumbfilename)
			{
				$data=array('propertyid'=>$commercialpropertyname,'elevation_image'=>$newfilename,'elevationthumbimg'=>$thumbfilename,'caption'=>$commercialcaption);
				$this->db->insert('commercialbuildingelevation',$data);
				return $this->db->insert_id();
			}
			
			function fetchcommercialelevation()
			{
				$testarr=array();
				$qry="select cb.elevation_id,pm.property_name,cb.elevation_image,cb.elevationthumbimg,cb.caption from commercialbuildingelevation cb inner join propertymaster pm on pm.propertyid=cb.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('elevation_id'=>$row->elevation_id,'propertyname'=>$row->property_name,'elevation_image'=>$row->elevation_image,'elevationthumbimg'=>$row->elevationthumbimg,'caption'=>$row->caption);
						
					}
				}
				return $testarr;
			}
			
		function insertresidentialcaption($propertyname,$residentialcaption,$name,$thumbfilename)
		{
			$data=array('propertyid'=>$propertyname,'elevationimage'=>$name,'elevationthumbimg'=>$thumbfilename,'caption'=>$residentialcaption);
			$this->db->insert('residentialbuildingelevation',$data);
			return $this->db->insert_id();
		}
		
		function fetchresidentialelevation()
		{
			$testarr=array();
			$qry="select rb.elevationid,pm.property_name,rb.elevationimage,rb.elevationthumbimg,rb.caption from residentialbuildingelevation rb inner join propertymaster pm on rb.propertyid=pm.propertyid";
			$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('elevationid'=>$row->elevationid,'property_name'=>$row->property_name,'elevationimage'=>$row->elevationimage,'elevationthumbimg'=>$row->elevationthumbimg,'caption'=>$row->caption);
						
					}
				}
				return $testarr;
		}
		
		function insertprofessional($firstname,$lastname,$designation)
		{
			$data=array('firstname'=>$firstname,'lastname'=>$lastname,'type'=>$designation);
			$this->db->insert('professionals',$data);
			return $this->db->insert_id();
		}
		
		function fetchprofessionallist()
		{
			$testarr=array();
			$qry="select * from professionals";
			$rs=$this->db->query($qry);
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('professional_id'=>$row->professional_id,'firstname'=>$row->firstname,'lastname'=>$row->lastname,'designation'=>$row->type);
				}
			}
			return $testarr;
		}
		
		function insertbanklist($bankname,$newfilename,$thumbfilename)
		{
			$data=array('bank_name'=>$bankname,'bank_logo'=>$newfilename,'thumb_logo'=>$thumbfilename);
			$this->db->insert('bankmaster',$data);
			return $this->db->insert_id();
		}
		
		function fetchbanklist()
		{
			$testarr=array();
			$qry="select * from bankmaster";
			$rs=$this->db->query($qry);
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('bankid'=>$row->bankid,'bank_name'=>$row->bank_name,'bank_logo'=>$row->bank_logo,'thumb_logo'=>$row->thumb_logo);
				}
			}
			return $testarr;
		}
		
		function fetchbanklistpage($num,$offset)
		{
			$testarr=array();
			$qry="select * from bankmaster limit " . $num . "," . $offset;
			$rs=$this->db->query($qry);
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('bankid'=>$row->bankid,'bank_name'=>$row->bank_name,'bank_logo'=>$row->bank_logo,'thumb_logo'=>$row->thumb_logo);
				}
			}
			return $testarr;
		}
		
		function addapprovedbankid($propertyid,$iactid)
		{
			$data=array('propertyid'=>$propertyid,'bankid'=>$iactid);
			$this->db->insert('residentialpropertyapprovedbank',$data);
			return $this->db->insert_id();
		}
		
		function addcommercialapprovedbankid($commercialpropertyid,$iactid)
		{
			$data=array('propertyid'=>$commercialpropertyid,'bankid'=>$iactid);
			$this->db->insert('commercialpropertyapprovedbank',$data);
			return $this->db->insert_id();
		}
		
		function insertresidentialconstructionstage($propertyname="",$stagedescription="",$name="",$thumbfilename="")
		{
			$data=array('propertyid'=>$propertyname,'stagedesc'=>$stagedescription,'stageimg'=>$name,'stagethumbimg'=>$thumbfilename);
			$this->db->insert('residentialconstructionstage',$data);
			return $this->db->insert_id();
		}
		
		function fetchresidentialconstruction()
		{
			$testarr=array();
			$qry="select pm.property_name,rcs.stageid,rcs.stagedesc,rcs.stageimg,rcs.stagethumbimg from propertymaster pm inner join residentialconstructionstage rcs on pm.propertyid=rcs.propertyid";
			$rs=$this->db->query($qry);
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('stageid'=>$row->stageid,'property_name'=>$row->property_name,'stagedesc'=>$row->stagedesc,'stageimg'=>$row->stageimg,'stagethumbimg'=>$row->stagethumbimg);
				}
			}
			return $testarr;
		}
		
		function insertcommercialconstructionstage($commercialpropertyname="",$commercialstagedesc="",$newfilename="",$thumbfilename="")
		{
			$data=array('propertyid'=>$commercialpropertyname,'stagedesc'=>$commercialstagedesc,'stageimg'=>$newfilename,'stagethumbimg'=>$thumbfilename);
			$this->db->insert('commercialconstructionstage',$data);
			return $this->db->insert_id();
		}
		
		function fetchcommercialconstruction()
		{
			$testarr=array();
				$qry="select cs.commercialstageid,pm.property_name,cs.stageimg,cs.stagethumbimg,cs.stagedesc from commercialconstructionstage cs inner join propertymaster pm on pm.propertyid=cs.propertyid";
				$rs=$this->db->query($qry);
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('commercialstageid'=>$row->commercialstageid,'propertyname'=>$row->property_name,'stageimg'=>$row->stageimg,'stagethumbimg'=>$row->stagethumbimg,'stagedesc'=>$row->stagedesc);
						
					}
				}
				return $testarr;
		}
		
		function insertresidentialbrochure($propertyname,$name)
		{
			$data=array('propertyid'=>$propertyname,'brochuretype'=>$name);
			$this->db->insert('residentialbrochure',$data);
			return $this->db->insert_id();
		}
		
		function insertcommercialbrochure($propertyname,$name)
		{
			$data=array('propertyid'=>$propertyname,'brochuretype'=>$name);
			$this->db->insert('commercialbrochure',$data);
			return $this->db->insert_id();
		}
		
		function insertpropertyvideo($propertyname,$newfilename)
		{
			$data=array('propertyid'=>$propertyname,'videotype'=>$newfilename);
			$this->db->insert('residentialvideo',$data);
			return $this->db->insert_id();
		}
		
		function insertcommercialpropertyvideo($propertyname,$name)
		{
			$data=array('propertyid'=>$propertyname,'videotype'=>$name);
			$this->db->insert('commercialvideo',$data);
			return $this->db->insert_id();
		}
		
		
		
		//edit operation starts

			function editcitylist($cityid)
			{
				$testarr=array();
				$qry="select * from citylist where cityid =?";
				$rs=$this->db->query($qry,array($cityid));
				if($rs->num_rows()>0)
					{
						foreach($rs->result() as $row)
						{
						 $testarr[]=array('cityid'=>$row->cityid,'cityname'=>$row->cityname);
						}
					}
				return $testarr;
			}
			
			function updatecitylist($cityid,$cityname)
			{
				$data = array("cityname" => $cityname);
				$this->db->where('cityid',$cityid);
				$this->db->update('citylist',$data);
			}
			
			function editcityarealist($localityid)
			{
				$testarr=array();
				$qry="select c.cityid,c.cityname from citylist c where c.cityid=?";
				$rs=$this->db->query($qry,array($localityid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
					$testarr[]=array('cityid'=>$row->cityid,'cityname'=>$row->cityname);
					}
				}
				return $testarr;
			}
			
			function updatecityarealist($localityid,$locality)
			{
				$data = array("cityname" => $locality);
				$this->db->where('cityid',$localityid);
				$this->db->update('citylist',$data);
			}
			
			function editbanklist($bankid)
			{
				$testarr=array();
			$qry="select * from bankmaster where bankid=?";
			$rs=$this->db->query($qry,array($bankid));
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('bankid'=>$row->bankid,'bank_name'=>$row->bank_name,'bank_logo'=>$row->bank_logo);
				}
			}
			return $testarr;
			}
			
			function updatebanklist($bankid,$bankname)
			{
				$data = array("bank_name" => $bankname);
				$this->db->where('bankid',$bankid);
				$this->db->update('bankmaster',$data);
			}
			
			function editbanklogo($bankid)
			{
				$testarr=array();
			$qry="select * from bankmaster where bankid=?";
			$rs=$this->db->query($qry,array($bankid));
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('bankid'=>$row->bankid,'bank_name'=>$row->bank_name,'bank_logo'=>$row->bank_logo);
				}
			}
			return $testarr;
			}
			
			function updatebanklogo($bankid,$name,$thumbfilename)
			{
				$data = array("bank_logo" =>$name,"thumb_logo"=>$thumbfilename);
				$this->db->where('bankid',$bankid);
				$this->db->update('bankmaster',$data);
			}
			
			function editproptype($typeid)
			{
				$testarr=array();
				$qry="select * from property_type where typeid=?";
				$rs=$this->db->query($qry,array($typeid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('typeid'=>$row->typeid,'propertytype'=>$row->propertytype);
					}
				}
				return $testarr;
			}
			
			function updateproptype($typeid,$proptype)
			{
				$data = array("propertytype" => $proptype);
				$this->db->where('typeid',$typeid);
				$this->db->update('property_type',$data);
			}
			
			function editcategory($catid)
			{
				$testarr=array();
				$qry="select * from category inner join property_type on category.propertytypeid=property_type.typeid where category.categoryid=?";
				$rs=$this->db->query($qry,array($catid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertytype'=>$row->propertytype,'categoryid'=>$row->categoryid,'categoryname'=>$row->categoryname);
					}
				}
				return $testarr;
			}
			
			function updatecategory($catid,$category)
			{
				$data = array("categoryname" => $category);
				$this->db->where('categoryid',$catid);
				$this->db->update('category',$data);
			}
			
			function editprofessional($professionalid)
			{
				$testarr=array();
			$qry="select * from professionals where professional_id=?";
			$rs=$this->db->query($qry,array($professionalid));
			if($rs->num_rows()>0)
			{
				foreach($rs->result() as $row)
				{
					$testarr[]=array('professional_id'=>$row->professional_id,'firstname'=>$row->firstname,'lastname'=>$row->lastname,'designation'=>$row->type);
				}
			}
			return $testarr;
			}
			
			function updateprofessional($professionalid,$firstname,$lastname,$designation)
			{
				$data = array("firstname" => $firstname,'lastname'=>$lastname,'type'=>$designation);
				$this->db->where('professional_id ',$professionalid);
				$this->db->update('professionals',$data);
			}
			
			function editresidentialspecification($specificationid)
			{
				$testarr=array();
				$qry="select * from residentialspecification rs inner join propertymaster pm on rs.propertyid=pm.propertyid where rs.specification_id=?";
				$rs=$this->db->query($qry,array($specificationid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('specificationid'=>$row->specification_id,'propertyname'=>$row->property_name,'specificationname'=>$row->specification_name);
					}
				}
				return $testarr;
			}
			
			function updateresidentialspecification($specificationid,$specificationname)
			{
				$data = array("specification_name" => $specificationname);
				$this->db->where('specification_id',$specificationid);
				$this->db->update('residentialspecification',$data);
			}
			
			function editresidentialamenities($amenitiesid)
			{
				$testarr=array();
				$qry="select * from residentialamenities ra inner join propertymaster pm on ra.propertyid=pm.propertyid where ra.residentialamenitiesid=?";
				$rs=$this->db->query($qry,array($amenitiesid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('residentialamenitiesid'=>$row->residentialamenitiesid,'propertyname'=>$row->property_name,'amenitiesname'=>$row->amenities_name);
					}
				}
				return $testarr;
			}
			
			function updateresidentialamenities($amenitiesid,$amenitiesname)
			{
				$data = array("amenities_name" => $amenitiesname);
				$this->db->where('residentialamenitiesid',$amenitiesid);
				$this->db->update('residentialamenities',$data);
			}
			
			function editresidentialplan($planid)
			{
				$testarr=array();
				$qry="select * from propertyresidentialplan rp inner join propertymaster pm on rp.propertyid=pm.propertyid where rp.planid=?";
				$rs=$this->db->query($qry,array($planid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('planid'=>$row->planid,'propertyname'=>$row->property_name,'plantype'=>$row->plantype);
					}
				}
				return $testarr;
			}
			
			function updateresidentialplan($planid,$plantype)
			{
				$data = array("plantype" => $plantype);
				$this->db->where('planid',$planid);
				$this->db->update('propertyresidentialplan',$data);
			}
			
			function updateresidentialplanimage($planid,$newfilename,$thumbfilename)
			{
				$data = array("planimg" => $newfilename,"planthumbimg"=>$thumbfilename);
				$this->db->where('planid',$planid);
				$this->db->update('propertyresidentialplan',$data);
			}
			
			function getcatnamefromid($residentialpropid)
			{
				$qry="select categoryname from propertymaster pm inner join category c on pm.categoryid=c.categoryid where pm.propertyid=?";
				$rs=$this->db->query($qry,array($residentialpropid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$catname=$row->categoryname;
					}
				}
				return $catname;
			}
			
			function editresidentialapptproperty($residentialpropid)
			{
				$testarr=array();
				$qry="select * from propertymaster pm where pm.propertyid=?";
				$rs=$this->db->query($qry,array($residentialpropid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertyid'=>$row->propertyid,'propertyname'=>$row->property_name,'address'=>$row->address,'buildername'=>$row->builders_name,'project'=>$row->aboutproject,'developer'=>$row->aboutdeveloper);
					}
				}
				return $testarr;
			}
			
			function editcommercialproperty($commercialpropid)
			{
				$testarr=array();
				$qry="select * from propertycommercial where propertycommercialid=? ";
				$rs=$this->db->query($qry,array($commercialpropid));
				if($rs->num_rows()>0)
				{
					foreach($rs->result() as $row)
					{
						$testarr[]=array('propertycommercialid'=>$row->propertycommercialid,'propertycommercialname'=>$row->propertycommercialname,'builders_name'=>$row->builders_name,'price'=>$row->price,'address'=>$row->address,'about_project'=>$row->about_project,'about_developer'=>$row->about_developer,'builtup_area'=>$row->builtup_area,'number_of_floors'=>$row->number_of_floors,'completion_date'=>$row->completion_date,'possession'=>$row->possession);
					}
				}
				return $testarr;
			}
			
			function updatecommercialproperty($propertycommercialid,$propertyname,$project,$buildername,$developer,$address,$propertyprice,$propertybuiltuparea,$propertyfloors,$propertycompletion,$propertypossession,$lat,$long)
			{
				$data = array("propertycommercialname" => $propertyname,'builders_name'=>$buildername,'address'=>$address,'price'=>$propertyprice,'about_project'=>$project,'about_developer'=>$developer,'builtup_area'=>$propertybuiltuparea,'number_of_floors'=>$propertyfloors,'completion_date'=>$propertycompletion,'possession'=>$propertypossession,'latitude'=>$lat,'longitude'=>$long);
				$this->db->where('propertycommercialid ',$propertycommercialid);
				$this->db->update('propertycommercial',$data);
			}
			
			
			
			
			
		}
?>